package cn.itsource.openfeign.fallback;

import cn.itsource.openfeign.EsCourseFeignClient;
import cn.itsource.ymcc.common.result.JsonResult;
import cn.itsource.ymcc.domain.CourseDoc;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class EsCourseFeignClientFallbackFactory implements FallbackFactory<EsCourseFeignClient> {
    @Override
    public EsCourseFeignClient create(Throwable throwable) {
        return new EsCourseFeignClient() {
            @Override
            public JsonResult saveCourseToEs(List<CourseDoc> courseDoc) {
                return JsonResult.error("es服务saveCourseToEs调用失败");
            }

            @Override
            public JsonResult getCourseDocByCourseIds(List<Long> ids) {
                return JsonResult.error("es服务getCourseDocByCourseIds调用失败");
            }
        };
    }
}
